<html>
<head><meta charset="utf-8"><title>object safe for dispatch #57545 · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html">object safe for dispatch #57545</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="163751974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163751974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163751974">(Apr 19 2019 at 17:58)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="131694">@scalexm</span> -- I am curious to get your thoughts on something. Have you seen <a href="https://rust-lang.github.io/rfcs/2027-object_safe_for_dispatch.html" target="_blank" title="https://rust-lang.github.io/rfcs/2027-object_safe_for_dispatch.html">RFC 2027</a>? It proposes a change to the way that <code>dyn Foo</code> types work, <a href="https://rust-lang.github.io/rfcs/2027-object_safe_for_dispatch.html#detailed-design" target="_blank" title="https://rust-lang.github.io/rfcs/2027-object_safe_for_dispatch.html#detailed-design">summarized here</a>. In short the idea is this:</p>
<p>Today, the type <code>dyn Foo</code> is only legal if the trait <code>Foo</code> is object-safe, and <code>dyn Foo: Foo</code> always holds.</p>
<p>Under this proposal, <code>dyn Foo</code> is always well-formed as a type, but <code>dyn Foo: Foo</code> only holds if <code>Foo</code> is object safe.</p>



<a name="163751985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163751985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163751985">(Apr 19 2019 at 17:58)</a>:</h4>
<p>One of the things that we've been talking about is the interaction of <code>dyn Foo</code> and implied bounds, and I wanted to bring this to your attention.</p>



<a name="163752076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163752076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163752076">(Apr 19 2019 at 18:00)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I’ve read it, and I think I concluded it was impossible to implement it soundly, but I can’t remember how I got to that conclusion</p>



<a name="163752137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163752137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163752137">(Apr 19 2019 at 18:00)</a>:</h4>
<p>that sounds like a concern :)</p>



<a name="163752141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163752141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163752141">(Apr 19 2019 at 18:00)</a>:</h4>
<p>I sort of have this nagging feeling too</p>



<a name="163752153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163752153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163752153">(Apr 19 2019 at 18:00)</a>:</h4>
<p>I think it was (as always) related with the <code>dyn Animal&lt;‘static&gt;</code> thing</p>



<a name="163752159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163752159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163752159">(Apr 19 2019 at 18:00)</a>:</h4>
<p>Yes, presumably.</p>



<a name="163752271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163752271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163752271">(Apr 19 2019 at 18:02)</a>:</h4>
<p>I’m in a train right now, basically doing nothing, so I can try to recollect the details</p>



<a name="163752770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163752770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163752770">(Apr 19 2019 at 18:09)</a>:</h4>
<p>Ok so the setup was:</p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">Animal</span><span class="o">&lt;</span><span class="n">X</span><span class="o">&gt;</span>: <span class="nb">&#39;static</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</pre></div>


<p>and how to think about <code>dyn Animal&lt;&amp;'a i32&gt;</code></p>



<a name="163752891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163752891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163752891">(Apr 19 2019 at 18:10)</a>:</h4>
<p>If you have that those two things to hold:</p>
<ul>
<li><code>dyn Animal&lt;&amp;'i32&gt;</code> is not considered ill-formed</li>
<li><code>Implemented(dyn Animal&lt;&amp;'a i32&gt;: Animal&lt;&amp;'a i32&gt;)</code> is considered to hold</li>
</ul>
<p>Then this is unsound (because of the <code>Projector</code> trick)</p>



<a name="163752913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163752913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163752913">(Apr 19 2019 at 18:11)</a>:</h4>
<p>So under the RFC, the first point must be always true, so we must ensure that the second point does not hold</p>



<a name="163752934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163752934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163752934">(Apr 19 2019 at 18:11)</a>:</h4>
<p>And I don’t know how to do that</p>



<a name="163753046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163753046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163753046">(Apr 19 2019 at 18:12)</a>:</h4>
<p>So probably I did not actually get to a firm conclusion « this is impossible to implement it soundly », more like « I don’t know how to make it sound » :)</p>



<a name="163753082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163753082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163753082">(Apr 19 2019 at 18:13)</a>:</h4>
<p>Especially under the model I described for trait objects to fix the above soundness problem, the RFC could not work as <code>dyn Animal&lt;&amp;'a i32&gt;</code> would not be considered well formed</p>



<a name="163753641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163753641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163753641">(Apr 19 2019 at 18:20)</a>:</h4>
<p>This reminds me, <span class="user-mention" data-user-id="131694">@scalexm</span>, that I think it'd be a good idea for us to try and do some "design presentations" on implied bounds. Basically spelling out how the current lowering works and what its effects are, to try and make sure people understand it. (And then, as a capstone, we could dive into the trait object questions.)</p>



<a name="163753650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163753650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163753650">(Apr 19 2019 at 18:20)</a>:</h4>
<p>I would like to make a kind of list of "complex questions to tackle" around traits</p>



<a name="163753658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163753658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163753658">(Apr 19 2019 at 18:20)</a>:</h4>
<p>So far we said that on monday we'll start digging into the built-in bounds problem, starting by explaining the SLG solve etc</p>



<a name="163753674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163753674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163753674">(Apr 19 2019 at 18:20)</a>:</h4>
<p>Which seems good -- and I suspect we should just keep our focus there until we feel like we've worked out the things that arise</p>



<a name="163753680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163753680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163753680">(Apr 19 2019 at 18:20)</a>:</h4>
<p>But maybe then we can turn to implied bounds a bit</p>



<a name="163753690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163753690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163753690">(Apr 19 2019 at 18:20)</a>:</h4>
<blockquote>
<p>So under the RFC, the first point must be always true, so we must ensure that the second point does not hold</p>
</blockquote>
<p>it's not <em>entirely</em> clear to me that the first point must be true</p>



<a name="163753707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163753707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163753707">(Apr 19 2019 at 18:21)</a>:</h4>
<p>i.e., that trait is presumably object safe anyway</p>



<a name="163753715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163753715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163753715">(Apr 19 2019 at 18:21)</a>:</h4>
<p>(right?)</p>



<a name="163753727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163753727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163753727">(Apr 19 2019 at 18:21)</a>:</h4>
<p>so it's not clear why this RFC even matters when it comes to this example</p>



<a name="163753805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163753805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163753805">(Apr 19 2019 at 18:22)</a>:</h4>
<p>I mean, the RFC states that <code>dyn Trait</code> must always be well-formed</p>



<a name="163753852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163753852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163753852">(Apr 19 2019 at 18:23)</a>:</h4>
<p>So if we want to fix the soundness issue under the RFC, we must ensure that we cannot prove <code>dyn Animal&lt;&amp;'a i32&gt;: Animal&lt;&amp;'a i32&gt;</code></p>



<a name="163753972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163753972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163753972">(Apr 19 2019 at 18:24)</a>:</h4>
<blockquote>
<p>I mean, the RFC states that <code>dyn Trait</code> must always be well-formed</p>
</blockquote>
<p>I'm not clear that it states this, or meant to state this</p>



<a name="163753977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163753977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163753977">(Apr 19 2019 at 18:24)</a>:</h4>
<p>I'm also not clear on whether this RFC still makes sense</p>



<a name="163754071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163754071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163754071">(Apr 19 2019 at 18:25)</a>:</h4>
<p>yes maybe it does not say that after all indeed</p>



<a name="163754186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163754186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163754186">(Apr 19 2019 at 18:26)</a>:</h4>
<p>But at least it is definitely incompatible with the trait objects model I though about; as under that model you somehow had:<br>
<code>WellFormed(dyn Trait)</code> iff <code>dyn Trait: Trait &amp;&amp; ObjectSafe(Trait)</code></p>



<a name="163754211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163754211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163754211">(Apr 19 2019 at 18:27)</a>:</h4>
<p>The iff was there to make implied bounds work correctly</p>



<a name="163754794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163754794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163754794">(Apr 19 2019 at 18:35)</a>:</h4>
<p>To put that model I thought of back in cache, the idea was the following:</p>
<ul>
<li>Object safe traits can only have supertraits and bound on type parameters</li>
<li>we have one rule: <code>WellFormed(dyn Trait&lt;X&gt;) :- WellFormed(dyn Trait&lt;X&gt;: Trait&lt;X&gt;) &amp;&amp; ObjectSafe(Trait)</code></li>
<li>we have one reverse rule: <code>FromEnv(dyn Trait&lt;X&gt;: Trait&lt;X&gt;) :- FromEnv(dyn Trait&lt;X&gt;)</code></li>
<li>we can easily get the set of all super traits of a trait <code>trait Trait&lt;X&gt;</code></li>
<li>for all that super traits (including the trait itself), we would generate a synthetic impl: <code>impl&lt;X&gt; SuperTrait&lt;...&gt; for dyn Trait&lt;X&gt;</code>: these impls are <em>always</em> legal thanks to the <code>FromEnv</code> rule</li>
</ul>



<a name="163754891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163754891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163754891">(Apr 19 2019 at 18:36)</a>:</h4>
<p>This all plays nicely with implied bounds (i.e. if you have <code>dyn Trait</code> as an input type you get all the bounds), <em>but</em> the constraint that you need to prove <code>WellFormed(dyn Trait: Trait)</code> to prove <code>WellFormed(dyn Trait)</code> fixes the <code>Animal&lt;&amp;'a i32&gt;</code> issue</p>



<a name="163754962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163754962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163754962">(Apr 19 2019 at 18:37)</a>:</h4>
<p>For some reason I'm having some trouble following this setup :)</p>



<a name="163755013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755013">(Apr 19 2019 at 18:38)</a>:</h4>
<p>Because in that case proving <code>WellFormed(dyn Animal&lt;&amp;'a i32&gt;: Animal&lt;&amp;'a i32&gt;)</code> would eventually reduce to proving <code>dyn Animal&lt;&amp;'a i32&gt;: 'static</code> which you cannot do</p>



<a name="163755086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755086">(Apr 19 2019 at 18:39)</a>:</h4>
<p>I think I have to remember what you mean by <code>WellFormed(TraitRef)</code> =)</p>



<a name="163755088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755088">(Apr 19 2019 at 18:39)</a>:</h4>
<p>That's..part of it</p>



<a name="163755099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755099">(Apr 19 2019 at 18:39)</a>:</h4>
<p>we never did settle on the best names for these things I think</p>



<a name="163755174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755174">(Apr 19 2019 at 18:40)</a>:</h4>
<p>Yeah <code>WellForme(TraitRef)</code> still means « all the transitive super bounds hold »</p>



<a name="163755192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755192">(Apr 19 2019 at 18:40)</a>:</h4>
<p>Including <code>Implemented(TraitRef)</code> itself</p>



<a name="163755201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755201">(Apr 19 2019 at 18:40)</a>:</h4>
<p>Right, ok. <code>FullyImplemented</code> or something like that</p>



<a name="163755207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755207">(Apr 19 2019 at 18:41)</a>:</h4>
<p>was another name we had kicked about</p>



<a name="163755227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755227">(Apr 19 2019 at 18:41)</a>:</h4>
<p>although I sort of recall thinking we should just call it <code>Implemented</code> and instead have <code>ShallowImplemented</code> for "I found an impl". Anyway.</p>



<a name="163755234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755234">(Apr 19 2019 at 18:41)</a>:</h4>
<p>In the <code>Animal</code> case, the <code>Implemented</code> part is covered by the synthetic impl, however the <code>'static</code> part is fully syntactic and cannot be proven</p>



<a name="163755238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755238">(Apr 19 2019 at 18:41)</a>:</h4>
<p>Yeah right</p>



<a name="163755256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755256">(Apr 19 2019 at 18:41)</a>:</h4>
<p>I guess for full clarity we can just do <code>FullyImplemented</code> and <code>ShallowImplemented</code></p>



<a name="163755262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755262">(Apr 19 2019 at 18:42)</a>:</h4>
<p>(or <code>Deeply</code>)</p>



<a name="163755308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755308">(Apr 19 2019 at 18:42)</a>:</h4>
<p>Sounds good indeed</p>



<a name="163755363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755363">(Apr 19 2019 at 18:43)</a>:</h4>
<p>I still have this issue in chalk with a lot of examples: <a href="https://github.com/rust-lang/chalk/issues/203" target="_blank" title="https://github.com/rust-lang/chalk/issues/203">https://github.com/rust-lang/chalk/issues/203</a></p>



<a name="163755376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755376">(Apr 19 2019 at 18:43)</a>:</h4>
<p>(Regarding trait objects)</p>



<a name="163755401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755401">(Apr 19 2019 at 18:44)</a>:</h4>
<p>To me, that setup is not that different from rustc’s current setup (we do have synthetic impls for all super traits of a trait objet)</p>



<a name="163755403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755403">(Apr 19 2019 at 18:44)</a>:</h4>
<p>In any case, the problem I guess is that where you had</p>
<div class="codehilite"><pre><span></span>WellFormed(dyn Trait&lt;X&gt;) :- DeeplyImplemented(dyn Trait&lt;X&gt;: Trait&lt;X&gt;) &amp;&amp; ObjectSafe(Trait)
</pre></div>


<p>we would want to change this to remove the <code>ObjectSafe</code> part, but of course it is really just <em>moving</em> into the <code>DeeplyImplemented(dyn Trait&lt;X&gt;: Trait&lt;X&gt;)</code> predicate, so we would still have that <code>WellFormed(dyn Trait&lt;X&gt;)</code> does not hold.</p>



<a name="163755459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755459">(Apr 19 2019 at 18:44)</a>:</h4>
<p>The new part is the well-formedness rule of a trait object</p>



<a name="163755492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755492">(Apr 19 2019 at 18:44)</a>:</h4>
<p>What we sort of want would be something like <code>WellFormed(dyn Trait&lt;X&gt;) :- "predicates of Trait&lt;X&gt; apply"</code>..maybe?</p>



<a name="163755498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755498">(Apr 19 2019 at 18:44)</a>:</h4>
<p>which might in turn give the error you are looked for?</p>



<a name="163755511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755511">(Apr 19 2019 at 18:44)</a>:</h4>
<p>Yes but under the RFC, <code>DeeplyImplemented(dyn Trait: Trait)</code> would <em>not</em> hold if the trait isn’t object safe</p>



<a name="163755519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755519">(Apr 19 2019 at 18:45)</a>:</h4>
<p>That the whole point of the RFC, I think</p>



<a name="163755527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755527">(Apr 19 2019 at 18:45)</a>:</h4>
<p>Right</p>



<a name="163755532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755532">(Apr 19 2019 at 18:45)</a>:</h4>
<p>But what I'm saying is</p>



<a name="163755546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755546">(Apr 19 2019 at 18:45)</a>:</h4>
<p>Ah</p>



<a name="163755549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755549">(Apr 19 2019 at 18:45)</a>:</h4>
<p>DeeplyImplemented proves:</p>
<ul>
<li>the trait is implemented (which would no longer hold, per the RFC)</li>
<li>all where clauses from the trait are satisfied (that's the deep part)</li>
</ul>



<a name="163755557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755557">(Apr 19 2019 at 18:45)</a>:</h4>
<p>but in some sense we might just want the second part?</p>



<a name="163755569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755569">(Apr 19 2019 at 18:45)</a>:</h4>
<p>Yes just strict super predicates</p>



<a name="163755583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755583">(Apr 19 2019 at 18:45)</a>:</h4>
<p>Maybe that would work</p>



<a name="163755885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755885">(Apr 19 2019 at 18:49)</a>:</h4>
<p>And in the <code>FromEnv(dyn Trait)</code> reverse rule you would only include the strict super predicates as well</p>



<a name="163755905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755905">(Apr 19 2019 at 18:49)</a>:</h4>
<p>Presumably, right</p>



<a name="163755910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755910">(Apr 19 2019 at 18:49)</a>:</h4>
<p>BTW, I wonder --</p>



<a name="163755974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755974">(Apr 19 2019 at 18:50)</a>:</h4>
<p>One of the challenges we've yet to discuss is extending to <code>dyn (Trait1 + Trait2)</code></p>



<a name="163755994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163755994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163755994">(Apr 19 2019 at 18:50)</a>:</h4>
<p>But I wonder if we could think instead about having a general <code>T = T1 &amp;&amp; T2</code> (I'm switching to intersection here, since the <code>+</code> is really "and", nor the "disjoint or" meaning it often has...)</p>



<a name="163756003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163756003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163756003">(Apr 19 2019 at 18:50)</a>:</h4>
<p>And then have <code>dyn Trait1 &amp;&amp; dyn Trait2</code></p>



<a name="163756017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163756017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163756017">(Apr 19 2019 at 18:50)</a>:</h4>
<p>Not sure how relevant that is, just occurred to me that it might be in some way easier</p>



<a name="163756036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163756036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163756036">(Apr 19 2019 at 18:51)</a>:</h4>
<p>i.e., <code>FromEnv(T1 &amp;&amp; T2) :- FromEnv(T1); FromEnv(T2).</code> and so forth</p>



<a name="163756042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163756042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163756042">(Apr 19 2019 at 18:51)</a>:</h4>
<p>basically it wouldn't require us to quantify over "things within types"</p>



<a name="163756049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163756049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163756049">(Apr 19 2019 at 18:51)</a>:</h4>
<p>Ah I see</p>



<a name="163756158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163756158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163756158">(Apr 19 2019 at 18:52)</a>:</h4>
<p>Yes I think that would work indeed</p>



<a name="163756360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163756360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163756360">(Apr 19 2019 at 18:55)</a>:</h4>
<p>Ok so regarding the RFC, just including strict predicates in the rule probably works indeed + moving the <code>ObjectSafe</code> bound to the synthetic impl for the trait itself</p>



<a name="163757529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163757529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163757529">(Apr 19 2019 at 19:09)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> ok then you’re right the RFC seems doable</p>



<a name="163757691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163757691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163757691">(Apr 19 2019 at 19:11)</a>:</h4>
<p>good, I guess</p>



<a name="163757699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163757699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163757699">(Apr 19 2019 at 19:11)</a>:</h4>
<p>bad because it means I have to put more work into reviewing this PR :P</p>



<a name="163758238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758238">(Apr 19 2019 at 19:19)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> lol</p>



<a name="163758269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758269">(Apr 19 2019 at 19:19)</a>:</h4>
<p>I wasn’t expecting to have it implemented before we actually fix trait objects, but I think that shouldn’t hurt</p>



<a name="163758288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758288">(Apr 19 2019 at 19:20)</a>:</h4>
<p>Also we probably won’t be able to stabilize until we do fix trait objects</p>



<a name="163758329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758329">(Apr 19 2019 at 19:20)</a>:</h4>
<p>To be sure there are no bad interactions</p>



<a name="163758605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758605">(Apr 19 2019 at 19:24)</a>:</h4>
<p>So <span class="user-mention" data-user-id="131694">@scalexm</span>, one other thing. For better or worse, <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=069fafa83436f65196ad6abefc83857d" target="_blank" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=069fafa83436f65196ad6abefc83857d">this code compiles today</a>:</p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">Animal</span><span class="o">&lt;</span><span class="n">X</span><span class="o">&gt;</span>: <span class="nb">&#39;static</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nc">dyn</span><span class="w"> </span><span class="n">Animal</span><span class="o">&lt;&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">u32</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="163758622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758622">(Apr 19 2019 at 19:25)</a>:</h4>
<p>Yes that does not surprise me</p>



<a name="163758625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758625">(Apr 19 2019 at 19:25)</a>:</h4>
<p>So it seems like that type cannot be made to be not well-formed</p>



<a name="163758643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758643">(Apr 19 2019 at 19:25)</a>:</h4>
<p>(Unless maybe I didn't quite understand what you were proposing)</p>



<a name="163758692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758692">(Apr 19 2019 at 19:26)</a>:</h4>
<p>Mmh you mean because it would break code?</p>



<a name="163758697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758697">(Apr 19 2019 at 19:26)</a>:</h4>
<p>Yes.</p>



<a name="163758704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758704">(Apr 19 2019 at 19:26)</a>:</h4>
<p>I was expecting to break code anyway</p>



<a name="163758705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758705">(Apr 19 2019 at 19:26)</a>:</h4>
<p>I suppose it could be considered a bug fix</p>



<a name="163758708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758708">(Apr 19 2019 at 19:26)</a>:</h4>
<p>Yes</p>



<a name="163758715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758715">(Apr 19 2019 at 19:26)</a>:</h4>
<p>But there's a real possibility we couldn't get away with that :)</p>



<a name="163758725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758725">(Apr 19 2019 at 19:26)</a>:</h4>
<p>But we should evaluate how big the breakage would be indeed</p>



<a name="163758732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758732">(Apr 19 2019 at 19:27)</a>:</h4>
<p>That said, I'm <em>also</em> not very happy with the outlives rules on trait objects</p>



<a name="163758739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758739">(Apr 19 2019 at 19:27)</a>:</h4>
<p>Which seems related here</p>



<a name="163758759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758759">(Apr 19 2019 at 19:27)</a>:</h4>
<p>Changing them would probably <em>also</em> be a breaking change</p>



<a name="163758821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758821">(Apr 19 2019 at 19:28)</a>:</h4>
<p>(I wonder if it could be done with an edition, actually)</p>



<a name="163758825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758825">(Apr 19 2019 at 19:28)</a>:</h4>
<p>Presumably it could</p>



<a name="163758836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758836">(Apr 19 2019 at 19:28)</a>:</h4>
<p>Changing the outlives rules for <code>fn</code> types (which I would also like to do) cannot be done w/ an edition though</p>



<a name="163758837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758837">(Apr 19 2019 at 19:28)</a>:</h4>
<p>Ah, you mean things like: <code>dyn Trait&lt;&amp;'a i32&gt; + 'static</code> being WF but <em>not</em> actually outliving <code>'static</code>?</p>



<a name="163758857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758857">(Apr 19 2019 at 19:28)</a>:</h4>
<p>right now they don't outlive <code>'static</code> but they could</p>



<a name="163758863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758863">(Apr 19 2019 at 19:28)</a>:</h4>
<p>Because that one is an annoying one which I did hit a few times in my code when multiple lifetimes and trait objects come to play</p>



<a name="163758868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758868">(Apr 19 2019 at 19:29)</a>:</h4>
<p>(in some universe)</p>



<a name="163758892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758892">(Apr 19 2019 at 19:29)</a>:</h4>
<p>it's more obvious to see with a type like <code>fn(&amp;'a u32)</code> -- like, there is no region data in there, so in some sense it should be <code>'static</code></p>



<a name="163758904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758904">(Apr 19 2019 at 19:29)</a>:</h4>
<p>but the same applies to the <code>X</code> in <code>dyn Trait&lt;X&gt;</code> -- it doesn't necessarily represent closed over data</p>



<a name="163758912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758912">(Apr 19 2019 at 19:29)</a>:</h4>
<p>Yes, but the <code>Projector</code> trick prevents it, unless you say that the arg type is not covered and you cannot implement generic impls for that fn type</p>



<a name="163758916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163758916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163758916">(Apr 19 2019 at 19:29)</a>:</h4>
<p>Yes I see</p>



<a name="163759019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163759019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163759019">(Apr 19 2019 at 19:31)</a>:</h4>
<p>It could make things simpler indeed, but this would break a lot of code for sure</p>



<a name="163759119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163759119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163759119">(Apr 19 2019 at 19:32)</a>:</h4>
<p>Whereas about making <code>dyn Animal&lt;&amp;'a i32&gt;</code> not WF maybe not as much breakage, as this soundness bug has remained hidden for a long time so I don’t think a lot of people rely on it</p>



<a name="163759143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163759143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163759143">(Apr 19 2019 at 19:32)</a>:</h4>
<p>So yeah maybe for another edition</p>



<a name="163759466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163759466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163759466">(Apr 19 2019 at 19:37)</a>:</h4>
<blockquote>
<p>It could make things simpler indeed, but this would break a lot of code for sure</p>
</blockquote>
<p>not entirely clear to me</p>



<a name="163759477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163759477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163759477">(Apr 19 2019 at 19:37)</a>:</h4>
<p>but maybe :)</p>



<a name="163759488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163759488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163759488">(Apr 19 2019 at 19:38)</a>:</h4>
<p>we could perhaps do a relatively...tailored rule</p>



<a name="163759564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163759564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163759564">(Apr 19 2019 at 19:38)</a>:</h4>
<p>e.g., this impl would be legal</p>
<div class="codehilite"><pre><span></span><span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">fn</span><span class="p">(</span><span class="n">T</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>


<p>but this one illegal</p>
<div class="codehilite"><pre><span></span><span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">fn</span><span class="p">(</span><span class="n">T</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">type</span> <span class="nc">Output</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>


<p>i.e., a generic type parameter (here, <code>T</code>) cannot appear in the value of an associated type unless it appears in some input type in a suitably constrained position (and fn/trait parameters do not count).</p>



<a name="163759565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163759565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163759565">(Apr 19 2019 at 19:39)</a>:</h4>
<p>I'm not sure how often that happens.</p>



<a name="163759589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163759589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163759589">(Apr 19 2019 at 19:39)</a>:</h4>
<p>In the trait case, we could do it with an edition for sure.</p>



<a name="163759596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163759596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163759596">(Apr 19 2019 at 19:39)</a>:</h4>
<p>Since we could use the older rules for older traits.</p>



<a name="163759608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163759608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163759608">(Apr 19 2019 at 19:39)</a>:</h4>
<p>Whether we <em>should</em> I don't know, butI think the curent rules are limiting.</p>



<a name="163759681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163759681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163759681">(Apr 19 2019 at 19:40)</a>:</h4>
<p>Yes ok the assoc type value is the problematic one and is probably less used indeed</p>



<a name="163759709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163759709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163759709">(Apr 19 2019 at 19:40)</a>:</h4>
<p>It's at least <em>plausible</em></p>



<a name="163759711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163759711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163759711">(Apr 19 2019 at 19:40)</a>:</h4>
<p>wish I had thought of that before</p>



<a name="163759722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/object%20safe%20for%20dispatch%20%2357545/near/163759722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/object.20safe.20for.20dispatch.20.2357545.html#163759722">(Apr 19 2019 at 19:40)</a>:</h4>
<p>I was never very happy with that part of the RFC, but it never occurred to me to make it this tailored.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>